import { createApp, markRaw } from "vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import "@/extension/jsExtension";
import {
  mApp,
  AppVue,
  emitter,
  MModal,
  routes,
  MDropdown,
  MDropdownMenuItem,
  DirectiveFocus,
  DirectiveSelect,
  locale,
  Portal,
  VueRouter
} from "@/mdesign-lib/mdesign-app.umd.js";
import "@/mdesign-lib/mdesign-app.css";
import "@/mdesign-lib/mdesign-graph.css";

import "@/modules/modelVerify/action/index";
const { createRouter, createWebHashHistory, routeLocationKey } = VueRouter;
(window as any).routeLocationKey = routeLocationKey;
const appVue = createApp(AppVue);
const router = createRouter({
  history: createWebHashHistory(),
  routes
});
appVue.use(router);
appVue.use(locale.i18n);
appVue.config.globalProperties.$global = mApp.global;
mApp.setRootVueApp(appVue);

// appVue.mixin({
//   updated() {
//     const file = this.$.type.__file as string;
//     if (file && file.endsWith('Footer.vue')) {
//       return;
//     } else {
//       console.log('comp updated', this.name, this.$.type.__file);

//     }
//   }
// });

appVue.config.globalProperties.$bus = emitter;
appVue.config.globalProperties.$global = mApp.global;

appVue.use(ElementPlus);

mApp.$router = markRaw(router);
appVue.component("m-modal", MModal);
appVue.component("m-dropdown", MDropdown);
appVue.component("m-dropdown-menu-item", MDropdownMenuItem);
appVue.directive("focus", DirectiveFocus);
appVue.directive("select", DirectiveSelect);
// appVue.directive('keyboard', DirectiveKeyboard);

appVue.mount("#app");

window.app = mApp;
console.log(mApp);
